/* bzflag
 * Copyright (c) 1993-2020 Tim Riker
 *
 * This package is free software;  you can redistribute it and/or
 * modify it under the terms of the license found in the file
 * named COPYING that should have accompanied this file.
 *
 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */

/*
 * ShotUpdate:
 *  Encapsulates info needed to update a shot on remote
 *  hosts. Can be packed for transmission on the net.
 *
 * FiringInfo:
 *  Encapsulates info needed to create ShotPath.
 *  Can be packed for transmission on the net.
 */

#ifndef BZF_SHOT_UPDATE_H
#define BZF_SHOT_UPDATE_H

// system headers
#include <math.h>

// local implementation headers
#include "common.h"
#include "Address.h"
#include "Flag.h"

const int       ShotUpdatePLen = PlayerIdPLen + 32;
const int       FiringInfoPLen = ShotUpdatePLen + 12;

class BaseLocalPlayer;

struct ShotUpdate
{
public:
    void*           pack(void*) const;
    const void*     unpack(const void*);

public:
    PlayerId        player;         // who's shot
    uint16_t        id;             // shot id unique to world
    float           pos[3];         // shot position
    float           vel[3];         // shot velocity
    float           dt;             // time shot has existed
    TeamColor       team;
};

struct FiringInfo
{
public:
    FiringInfo();
    FiringInfo(const BaseLocalPlayer&, int localID);

    void*           pack(void*) const;
    const void*     unpack(const void*);

public:
    float           timeSent;
    uint16_t         localID;        // ID local to the player
    ShotUpdate      shot;
    FlagType::Ptr       flagType;       // flag when fired
    float           lifetime;       // lifetime of shot (s)
};

#endif // BZF_SHOT_UPDATE_H

// Local Variables: ***
// mode: C++ ***
// tab-width: 4 ***
// c-basic-offset: 4 ***
// indent-tabs-mode: nil ***
// End: ***
// ex: shiftwidth=4 tabstop=4
